package com.whpost.service.dao.t;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.whpost.service.entity.t.TCzy;
import org.apache.ibatis.annotations.*;

public interface TCzyDao extends BaseMapper<TCzy> {

    //根据条件获取操作员信息
    @Select("select * from t_czy where ${ew.sqlSegment}")
    @Results(id="tCzyMap",value = {
            @Result(column="role_id",property="tRole",
                    one=@One(
                            select="com.whpost.service.dao.t.TRoleDao.selectById")
            ),
            @Result(column="xzjg_id",property="tXzjg",
                    one=@One(
                            select="com.whpost.service.dao.t.TXzjgDao.selectById")
            ),
            @Result(column="xzjg_id",property="xzjgId"),
            @Result(column="role_id",property="roleId")
    })
    IPage<TCzy> getTCzyLPage(Page<TCzy> page, @Param("ew") QueryWrapper wrapper);

    //获取用户密码
    @Select("select pwd from t_czy where id=#{lsh}")
    String getUserPwd(String lsh);

    //获取用户aes
    @Select("select aeskey from t_czy where id=#{lsh}")
    String getAesKey(String lsh);

    @Select("select * from t_czy where dlmc=#{dlmc}")
    @ResultMap(value="tCzyMap")
    TCzy getUseByDlmc(String dlmc);

    //更新密码
    @Update("update t_czy set pwd=#{pwd} where id = #{lsh}")
    int updateUserPwd(@Param(value = "pwd") String pwd, @Param(value = "lsh") String lsh);

    //更改用户状态
    @Update("update t_czy set state=#{state} where id = #{lsh}")
    int delCzy(@Param(value = "state") String state, @Param(value = "lsh") String lsh);

    @Select("select * from t_czy where id=#{lsh}")
    @ResultMap(value="tCzyMap")
    TCzy getCzyById(String lsh);

    @Update("update t_czy set headimg=#{tx} where id = #{id}")
    int updateTx(@Param(value = "tx") String tx, @Param(value = "id") String id);


}